# 10  给定一段英文文本，统计每个单词出现的次数；打印输出，按照词频从高到低输出：
import re
f = open('10.txt', 'r', encoding='utf-8')
content = f.read()
words = []
d = {}

# 正则匹配所有英文
wordlist = re.findall(r'[a-zA-Z]+', content)
# print(wordlist)

for word in wordlist:
    d[word] = d.get(word, 0) + 1
ls = list(d.items())
ls.sort(key=lambda x: x[1], reverse=True)

s = ''
for i in ls:
    s = '{}:{}'.format(i[0], i[1])
    print(s)

f.close()
